package com.yuuzai.openworld;

import org.apache.log4j.Logger;

import com.yuuzai.openworld.exceptions.Exceptions;
import com.yuuzai.openworld.exceptions.NullConfigurationException;

public abstract class OpenWorldObject {

	public void updateName() {
		if (name.isEmpty()) {
			name = UNNAMED;
		}
	}
	
	public static void assertNotNull(Object o) {
		if (o == null) {
			throw Exceptions.getException(NullConfigurationException.class, o);
		}
	}
	
	public long now() {
		return System.currentTimeMillis();
	}
	
	/* Definition */

	public static final Logger LOGGER = Logger.getLogger(OpenWorldObject.class);

	public static final String UNNAMED = "Unnamed Object";
	public static final String NULL_TO_STRING = "<null>";

	private String name;
	private String description;

	public void setName(String value) {
		this.name = value;
	}

	public String getName() {
		return this.name;
	}

	public void setDescription(String value) {
		this.description = value;
	}

	public String getDescription() {
		return this.description;
	}
	
	public String toString() {
		return this.name;
	}

}
